package com.hyou.springboot.annotation.validator;

import static java.lang.annotation.RetentionPolicy.RUNTIME;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import javax.validation.Constraint;
import javax.validation.Payload;

import com.hyou.springboot.validator.constraints.EnumRangeValidator;

/**
 * 枚举性质的数据取值范围校验 标记
 * 
 * @author FengChangshuo
 * @version 1.0.0 2018-03-28 10:35:42 初始创建
 */
@Documented
@Target({ ElementType.FIELD, ElementType.METHOD, ElementType.ANNOTATION_TYPE, ElementType.CONSTRUCTOR,
        ElementType.PARAMETER })
@Retention(RetentionPolicy.RUNTIME)
@Constraint(validatedBy = EnumRangeValidator.class)
public @interface EnumRange {
    
    String message() default "取值范围错误";
    
    /**
     * @return 取值范围
     */
    String[] range();
    
    Class<?>[] groups() default {};
    
    Class<? extends Payload>[] payload() default {};
    
    /**
     * Defines several {@code @EnumRange} annotations on the same element.
     */
    @Target({ ElementType.FIELD, ElementType.METHOD, ElementType.ANNOTATION_TYPE, ElementType.CONSTRUCTOR,
            ElementType.PARAMETER })
    @Retention(RUNTIME)
    @Documented
    public @interface List {
        EnumRange[] value();
    }
    
}
